package com.vision.controller;

import com.vision.pojo.AjaxResult;
import com.vision.service.LikeVideoService;
import org.apache.ibatis.annotations.Delete;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @projectName: vision
 * @package: com.vision.controller
 * @className: LikeVideoController
 * @author: escapeicon@gmail.com
 * @description: 视频点赞控制器
 * @date: 2024/1/28 10:13
 * @version: 1.0
 */
@RestController
@RequestMapping("/likeVideo")
public class LikeVideoController {

    @Autowired
    private LikeVideoService likeVideoService;

    /**
     * 添加视频点赞
     * @param videoId 视频id
     * @return 结果
     */
    @PostMapping("/addLikeVideo")
    public AjaxResult addLikeVideo(@NotNull Integer videoId) {
        likeVideoService.addLikeVideo(videoId);
        return AjaxResult.success();
    }

    /**
     * 取消视频点赞
     * @param videoId 视频id
     * @return 结果
     */
    @DeleteMapping("/cancelLikeVideo")
    public AjaxResult cancelLikeVideo(@NotNull Integer videoId) {
        likeVideoService.cancelLikeVideo(videoId);
        return AjaxResult.success();
    }
}
